package com.xianyun.consumer;

import com.xianyun.common.model.User;
import com.xianyun.common.service.UserService;
import com.xianyun.rpc.bootstrap.ConsumerBootstrap;
import com.xianyun.rpc.serverProxy.ServiceProxyFactory;

/**
 * 测试配置 rpc 的配置对象是否正确加载。
 *
 * @author xianYun
 * @version 1.0
 **/
public class ConsumerExample {
    public static void main(String[] args) {
        // 服务提供者初始化
        ConsumerBootstrap.init();

        // 获取代理
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setName("xianyun");
        // 调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getName());
            System.out.println("服务调用成功：" + userService.getAge());
        } else {
            System.out.println("user == null");
        }
    }

}
